package my.spring.aop;

import my.spring.aop.aspect.Advisor;

/**
 * 生成代理类的工厂
 * @author fengbo
 * @date 2018/6/30
 */
public class ProxyFactory implements Advised {

    private Object target;
    private Advisor advisor;

    public ProxyFactory(Object target, Advisor advisor) {
        this.target = target;
        this.advisor = advisor;
    }

    public Object getProxy() {
        return createAopProxy().getProxy();
    }

    public AopProxy createAopProxy() {
        return new JdkDynamicAopProxy(this);
    }

    /********************************************
     * Advised接口实现
     *********************************************/

    @Override
    public Object getTarget() {
        return target;
    }

    @Override
    public Advisor getAdvisor() {
        return advisor;
    }
}
